//
//  BaseViewController.swift
//  CJXSwiftStoryboard
//
//  Created by CJX on 2016/10/20.
//  Copyright © 2016年 caijianxi. All rights reserved.
//

import UIKit
let SCREEN_WIDTH = UIScreen.mainScreen().bounds.size.width
let SCREEN_HEIGHT = UIScreen.mainScreen().bounds.size.height
let APIBASE = "http://store.viprunningonline.com/api/index.php?"
import AFNetworking
import SVProgressHUD
import SwiftyJSON
import SDWebImage
import MJRefresh
import SnapKit

class BaseViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        self.title = "MainVC"
        self.navigationController?.navigationBar.barTintColor = UIColor.init(red: 94/255.0, green: 200/255.0, blue: 252/255.0, alpha: 1)
        let barItemFram = CGRectMake(0, 0, 44, 44);
        
        // Customize the UIBarButtonItem
        let leftItemCustomeView   = UIButton(type: UIButtonType.Custom);
        leftItemCustomeView.frame = barItemFram;
        leftItemCustomeView.setImage(UIImage(named:"nav_menu"), forState: UIControlState.Normal)
        
        let rightItemCustomeView   = UIButton(type: UIButtonType.Custom);
        rightItemCustomeView.frame = barItemFram;
        rightItemCustomeView.setImage(UIImage(named:"nav_me"), forState: UIControlState.Normal)
        
        leftItemCustomeView.addTarget(self, action: #selector(BaseViewController.leftButtonAction(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        rightItemCustomeView.addTarget(self, action: #selector(BaseViewController.rightButtonAction(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        self.navigationItem.leftBarButtonItem  = UIBarButtonItem(customView: leftItemCustomeView);
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: rightItemCustomeView);
        
        
    }
    
    
    
    // MARK: - IBAction Methods

    
    func leftButtonAction(sender: UIButton)
    {
        // with orange color
//        sender.layer.startAnimation(tintColor :UIColor.blackColor())
//        NSNotificationCenter.defaultCenter().postNotificationName(KVSideMenu.Notifications.toggleLeft, object: self)
        
        self.navigationController?.pushViewController(LeftSideViewController(), animated: true)
        
    }
    
    func rightButtonAction(sender: UIButton)
    {
        sender.layer.startAnimation1(tintColor :UIColor.blackColor())
        sender.layer.startAnimation1()
        NSNotificationCenter.defaultCenter().postNotificationName(KVSideMenu.Notifications.toggleRight, object: self)
        //   OR
        // self.sideMenuViewController()?.menuContainerView?.toggleRightSideMenu()
    }
    
    
}